package com.example.thirdstage_project.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.thirdstage_project.entity.Expert;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * 专家信息表(Expert)表数据库访问层
 *
 * @author makejava
 * @since 2022-11-24 15:19:04
 */
@Mapper
public interface ExpertDao extends BaseMapper<Expert> {
    /**
     *
     */
    @Select("select expertid,name,unitname,title,nation,sex,tel,introduction FROM expert")
    List<Expert> selectAll();

    /**
     * 更新信息
     */
    @Update("update mp.expert set name=#{name},unitname=#{unitname}," +
            "title=#{title},nation=#{nation}" +
            ",sex=#{sex},introduction=#{introdution} where expertid=#{expertid}")
    int update(Expert expert);

    /**
     * 删除
     */
    @Delete("delete expert,project_category from expert a left jion project_category b on expert.expertid=project_category.expertid where expertid=#{expertid}")
    int delete(Integer expertid);

    @Select("select expertid from mp.expert where uid=#{uid}")
    int selectid(int uid);


    @Select("select password from user where uid=#{uid}")
    int select(int uid);

    @Update("update mp.user set password=#{password} where uid=#{uid} ")
    int updatePassword(String password,int uid);
}

